package com.wenhai.xiaomage.spring.ioc.overview.dependency.lookup;

import com.wenhai.xiaomage.spring.ioc.overview.dependency.xml.replacedmethod.ChangeMethod;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author:wenhai
 * @Description: {@link AbstractBeanDefinition} 对应methodOverrides lookup配置示例
 * @Date:2020/4/6
 */
public class ReplacedMethodDemo {
    public static void main(String[] args) {
        ApplicationContext bf = new ClassPathXmlApplicationContext("META-INF/replaced-method-context.xml");
        ChangeMethod changeMethod = bf.getBean("changeMethod", ChangeMethod.class);
        changeMethod.changeMe();
        ConfigurableListableBeanFactory beanFactory = ((ClassPathXmlApplicationContext) bf).getBeanFactory();
        beanFactory.destroyBean(changeMethod);
    }
}
